<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增检测机构仪器设备')" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tJcJcjgJcyq-add">
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>设备编号：</label>
						<div class="col-sm-8">
							<input id="equipmentNo" name="equipmentNo"
								   class="form-control" type="text" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>设备名称：</label>
						<div class="col-sm-8">
							<input id="equipmentName" name="equipmentName"
								   class="form-control" type="text" required>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>设备型号：</label>
						<div class="col-sm-8">
							<input id="equipmentTypeNo" name="equipmentTypeNo"
								   class="form-control" type="text" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>是否校验：</label>
						<div class="col-sm-8" required>
							<label class="col-sm-4 control-label">
								<input type="radio" checked="" value="1" id="isCheck1" name="isCheck">是 </label>
							<label class="col-sm-4 control-label">
								<input type="radio" value="0" id="isCheck2" name="isCheck">否 </label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">校验结果：</label>
						<div class="col-sm-8">
							<input id="checkResult" name="checkResult" class="form-control" type="text">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">校验单位：</label>
						<div class="col-sm-8">
							<input id="checkStation" name="checkStation" class="form-control" type="text">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">校验日期：</label>
						<div class="col-sm-8">
							<input id="checkTime" name="checkTime" class="form-control" type="text" placeholder="yyyy-MM-dd">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">有效期起：</label>
						<div class="col-sm-8">
							<input id="startTime" name="startTime" class="form-control" type="text" placeholder="yyyy-MM-dd">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">有效期止：</label>
						<div class="col-sm-8">
							<input id="endTime" name="endTime" class="form-control" type="text" placeholder="yyyy-MM-dd">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
					<label class="col-sm-4 control-label">检测机构名称：</label>
					<div class="col-sm-8">
						<!--<input id="detectionName1" name="detectionName" placeholder="请输入检测机构名称" class="form-control" type="text" >-->
						<select name="jcjgId" id = "detectionName1" class="form-control m-b" onclick="query()">
							<option value= 0>请输入检测机构名称</option>
						</select>
						<input type="hidden" name="detectionName" id="checkTo">
					</div>
					</div>
				</div>
			</div>
		</form>
	</div>
	<div class="row">
		<div class="col-sm-offset-5 col-sm-10">
			<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保存</button>&nbsp;
			<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
		</div>
	</div>
	<script th:src="@{/js/city-picker.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/tJcJcjgJcyq";
		$("#checkTime").datetimepicker({
			format: "yyyy-mm-dd",
			minView: "month",
			autoclose: true
		});
		$("#startTime").datetimepicker({
			format: "yyyy-mm-dd",
			minView: "month",
			autoclose: true
		});
		$("#endTime").datetimepicker({
			format: "yyyy-mm-dd",
			minView: "month",
			autoclose: true
		});
		$("#form-tJcJcjgJcyq-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		function submitHandler() {
	        if ($.validate.form()) {
				var param=$("#form-tJcJcjgJcyq-add").serialize().split("&");
				param.splice(param.length-1,1).join("&")
				console.log(param)
	            $.operate.save(prefix + "/add", param);
	        }
	    }
		$(function () {
			check();
			// checkTo();
			detectionName1();
		})
		function check() {
			//省市区数据
			$.ajax({
				url: ctx + "system/tJcFlzddw/list",
				type: "post",
				dataType:"json",
				success:function (data) {
					// console.log(data)
					var data2 = data.rows;
					// alert(data2[i].unitName);
					// console.log(data2.length);
					for (var i in data2) {
						if (data2[i].unitName != null) {
							$("#check").append("<option value='" + data2[i].unitName + "'>" + data2[i].unitName + "</option>");
						}

					}
				}
			})
		}
		function query(){
			var detectionName = $("#detectionName1 option:selected").text();
			$("#checkTo").val(detectionName)
		}
		function detectionName1(){
			//各个机构单位信息
			$.ajax({
				url: ctx + "system/tJcFlzddw/option",
				type: "post",
				dataType:"json",
				success:function (data) {
					console.log(data)
					var data2 = data.rows;
					// alert(data2[i].unitName);
					// console.log(data2.length);
					// debugger
					for (var i in data2) {

						if (data2[i].agencyName != null) {
							$("#detectionName1").append("<option value='" + data2[i].code + "'>" + data2[i].agencyName + "</option>");
						}

					}
				}
			})
		}
	</script>
</body>
</html>
